package cn.ycl.system.biz.delivery.controller;

import cn.ycl.system.biz.delivery.entity.DeliveryAddress;
import cn.ycl.system.biz.delivery.service.DeliveryAddressService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (DeliveryAddress)表控制层
 *
 * @author yuanchangliang
 * @since 2021-10-19 10:36:15
 */
@RestController
@RequestMapping("/deliveryAddress")
public class DeliveryAddressController {
    /**
     * 服务对象
     */
    @Resource
    private DeliveryAddressService deliveryAddressService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    public DeliveryAddress selectOne(Long id) {
        return this.deliveryAddressService.queryById(id);
    }

    /**
     * 插入数据
     *
     * @param deliveryAddress 参数
     * @return 结果
     */
    @GetMapping("/insert")
    public String insert(DeliveryAddress deliveryAddress) {
        DeliveryAddress deliveryAddress1 = deliveryAddressService.insert(deliveryAddress);
        return "success";
    }

    /**
     * 修改数据
     *
     * @param deliveryAddress 主键
     * @return 单条数据
     */
    @GetMapping("/update")
    public String update(DeliveryAddress deliveryAddress) {
        DeliveryAddress deliveryAddress1 = deliveryAddressService.update(deliveryAddress);
        return "success";
    }

    /**
     * 获取前10条数据
     *
     * @return 单条数据
     */
    @GetMapping("/getAddressList")
    public List<DeliveryAddress> getAddressList() {
        return this.deliveryAddressService.getAddressList();
    }

}
